package nix.service.impl;

import java.util.List;

import nix.dao.SaleVisitDao;
import nix.domain.SaleVisit;
import nix.service.SaleVisitService;
import nix.utils.PageBean;

import org.hibernate.criterion.DetachedCriteria;

public class SaleVisitServiceImpl implements SaleVisitService {

	private SaleVisitDao saleVisitDao;

	@Override
	public void save(SaleVisit saleVisit) {
		saleVisitDao.savaOrUpdate(saleVisit);
	}

	@Override
	public PageBean getPageBean(DetachedCriteria dc, Integer currentPage,
			Integer pageSize) {
		
		int totalCount = saleVisitDao.getTotalCount(dc);
		PageBean pb = new PageBean(currentPage, totalCount, pageSize);
		List<SaleVisit> list = saleVisitDao.getPageList(dc, pb.getStart(), pb.getPageSize());
		pb.setList(list);
		return pb;
	}

	@Override
	public SaleVisit getById(String visit_id) {
		return saleVisitDao.getById(visit_id);
	}
	
	public void setSaleVisitDao(SaleVisitDao saleVisitDao) {
		this.saleVisitDao = saleVisitDao;
	}

}
